/*
 * @lc app=leetcode.cn id=46 lang=cpp
 *
 * [46] 全排列
 */
#include"0.cpp"
// @lc code=start
class Solution {   
public:
    vector<vector<int>> result;
    vector<int> path;
    void backtracking(vector<int> &nums,vector<bool> &used){
        if(path.size()==nums.size()){
            result.emplace_back(path);
            return;
        }
        for(int i=0;i<nums.size();i++){
            if(used[i]==true) continue;
            used[i]=true;
            path.emplace_back(nums[i]);
            backtracking(nums,used);
            used[i]=false;
            path.pop_back();
        }
        return;
    }
    vector<vector<int>> permute(vector<int>& nums) {
        vector<bool> used(nums.size(), false);
        backtracking(nums,used);
        return result;
    }
};
// @lc code=end

